package com.xmy.cultivate.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xmy.cultivate.entity.StudentSchool;
import com.xmy.cultivate.mapper.StudentSchoolMapper;
import com.xmy.cultivate.service.IStudentSchoolService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 学生所属于校区 服务实现类
 * </p>
 *
 * @author min
 * @since 2022-12-22
 */
@Service
public class StudentSchoolServiceImpl extends ServiceImpl<StudentSchoolMapper, StudentSchool> implements IStudentSchoolService {

    /**
     * 添加或修改
     * @param studentId
     * @param schoolId
     * @return
     */
    public boolean addOrUpdateData(Long studentId,Long schoolId){
        StudentSchool studentSchool = new StudentSchool();
        studentSchool.setStudentId(studentId);
        studentSchool.setSchoolId(schoolId);
        QueryWrapper<StudentSchool> studentSchoolQueryWrapper = new QueryWrapper<>();
        studentSchoolQueryWrapper.eq("student_id",studentId);
        studentSchoolQueryWrapper.eq("school_id",schoolId);
        this.saveOrUpdate(studentSchool,studentSchoolQueryWrapper);
        return true;

    }
}
